<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trang chủ</title>
<link rel="shortcut icon" href="../Images/Icons/SunstormLogo.gif" />
<link rel="stylesheet" href="../CSS/css_webnews.css"/>
<link href="../Menu_Zing/SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="../CSS/wt-rotator.css" rel="stylesheet" type="text/css" />
<link href="../CSS/slider.css" rel="stylesheet" type="text/css" />
<link href="../weather/weather.css" rel="stylesheet" type="text/css" />
<link href="../CSS/experiment.css" rel="stylesheet" type="text/css" />
 

<script src="../Menu_Zing/SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="../Scripts/preview.js" type="text/javascript"></script>
<script src="../Scripts/jquery.wt-rotator.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/jquery-ui.min.js" ></script>
<script language="javascript" src="../weather/js/ajax.js"></script>
<script language="javascript" src="../Scripts/floater_xlib.js"></script>
<script language="javascript" src="../Scripts/Advertise_twoside.js"></script>
<script language="javascript" src="../Scripts/boxover.js"></script>
<script language="javascript" src="../Scripts/jquery.jqDock.min.js"></script>

<style> 

     </style> 
</head>

<body>
<?php 
include("../Connections/connect_client.php");
require_once("include/Advertise_twoside.php");
function getSubMenu($parent)
{
	$submenu='';
	$res=mysql_query("SELECT t.TopicID FROM topic t WHERE t.IsDeleted=0 and t.ParentID=$parent");
	while($t=mysql_fetch_assoc($res))
	{
		$submenu.='<'.$t["TopicID"].'>';
		$submenu.=getSubMenu(intval($t["TopicID"]));
	}
	return $submenu;
}
?>
<div id="main">
  <div class="header"></div>
  <div class="menu"><?php
  $urlAds="../Images/Advertisement/";
  $urlNews="../Images/Img_News/";
  $urlIcon="../Images/Icons/";
  require("../Menu_Zing/Zing/MenuNgang.php");
  require("include/JdockMenu.php");
  require("include/Feedback_modal.php");?></div>
   <!----------------------------------------Bar Search + BreadCrumb------------------------------------------------------>
  <div class="searchBar" >
   <form action="SearchNews.php" method="get" id="frmQuicksearch">
    <div class="searchBox" >
        	<input type="text" placeholder="Tìm kiếm..." name="keyword"  />
            <input type="image" src="../Images/Icons/Knob Search.ico" onclick="form.frmQuicksearch.submit();"   />       
    </div>
  	</form>
  </div>
  <!----------------------------------------Content------------------------------------------------------>
  <div class="left">
  
  <!----------------------------------------------Slider News----------------------------------------------------->
  	<script type="text/javascript">
	$(document).ready(function(){
		$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	});
	</script>
  <div id="featured" >
		  <ul class="ui-tabs-nav">
          	<?php
			$topic=intval($_GET["topicID"]);
			$listTopic='<'.$topic.'>'.getSubMenu($topic);
			$topsql="SELECT n.NewsID,n.TopicID, n.Title, n.Description, n.Image,n.CreatedDate FROM news n WHERE n.IsDeleted=0 AND n.IsReview=1 AND '$listTopic' LIKE CONCAT('%<',n.TopicID,'>%') ORDER BY n.CreatedDate DESC LIMIT 0,4 ";
			$restop=mysql_query($topsql);
			$arrtop=array();
			$i=0;
			while($top=mysql_fetch_assoc($restop))
			{
				$arrtop[$i]=array(
								  'NewsID'=>$top["NewsID"],
								  'Title'=>$top["Title"],
								  'Description'=>$top["Description"],
								  'Image'=>$top["Image"]
								  );
				$i++;
			}
			for($j=0;$j<count($arrtop);$j++)
			{
			?>
	        <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $j; ?>"><a href="#fragment-<?php echo $j; ?>"><img style="width:80px; height:50px" src="<?php echo $urlNews.$arrtop[$j]["Image"]; ?>" alt="" /><span><?php echo $arrtop[$j]["Title"]; ?></span></a></li>
            <?php
			}
			?>
	      
	      </ul>

	    <?php
			for($j=0;$j<count($arrtop);$j++)
				{
					
		?>
	    <div id="fragment-<?php echo $j; ?>" class="ui-tabs-panel" style="">
			<img src="<?php echo $urlNews.$arrtop[$j]["Image"]; ?>" alt="" style="width:400px; height:250px" />
			 <div class="info" >
				<h2><a href="Detail.php?id=<?php echo $arrtop[$j]["NewsID"]; ?>" ><?php echo $arrtop[$j]["Title"]; ?></a></h2>
				<p><?php echo $arrtop[$j]["Description"]; ?></p>
			 </div>
	    </div>
		<?php
				}
		?>
	   
		</div>
  <!----------------------------------------------End Slider----------------------------------------------------->
  <!----------------------------------------------News----------------------------------------------------->
  <div id="content">
  <!--Tin 1--->
 
  <div class="div_topic">
    
    <?php
		$page=1;
		$recordPerPage=10;
		if(isset($_GET["page"]))
			{
				$page=intval($_GET["page"]);
			}
		$index=($page-1)*$recordPerPage+4;
		$sqlAll="SELECT n.NewsID, n.NewsType, n.TopicID, n.Title, n.Description, n.Image, n.IsHot,n.CreatedDate FROM news n WHERE n.IsDeleted=0 AND n.IsReview=1 AND '$listTopic' LIKE CONCAT('%<',n.TopicID,'>%') ORDER BY n.CreatedDate DESC";
		$sqlnews=$sqlAll." LIMIT $index,$recordPerPage ";
		$resnews=mysql_query($sqlnews);
		while($fnews=mysql_fetch_assoc($resnews))
		{
	?>
    <div class="tp_content">
    	<div class="top_news" style="width:100%">
        	<a href="Detail.php?id=<?php echo $fnews["NewsID"]; ?>" title="">
            	<img src="<?php echo $urlNews.$fnews["Image"]; ?>" alt="" style="width:150px; margin:8px" />
            </a>
            <div style="float:left; width:490px;margin-top: 5px;">
            	<a href="Detail.php?id=<?php echo $fnews["NewsID"]; ?>" title="">
                <?php 
					echo $fnews["Title"];
					if($fnews["NewsType"]==1)
						echo "<img src='".$urlIcon."photo.gif' alt='' />";
					else if($fnews["NewsType"]==2)
						echo "<img src='".$urlIcon."video.gif' alt='' />";
					if($fnews["IsHot"]==1)
						echo "<img src='".$urlIcon."hot.gif' alt='' />";
				?> 
                </a>
                <br />
                <p><?php echo $fnews["Description"]; ?></p>
            </div>
        </div>
         <div style="clear:both"></div>
    </div>
        <?php
		}
		?>
       <div class="pagination pull-right">
   <?php require("../Admin/process/funcPaging.php");
			
				
			$link="GroupNews.php?topicID=$topic&";
			
			$resAll=mysql_query($sqlAll);
			$total=mysql_num_rows($resAll)-4;
			
			Paging($total,$page,5,$recordPerPage,$link);
 		?>  
    </div>
  </div>

  
  <!----End--->
  </div>
<!----------------------------------------------End News----------------------------------------------------->
  </div>
  <div class="right">
  <!----------------------------------------------Weather+Stock----------------------------------------------------->
  	<div id="weather">
    <?php include("../weather/index.php"); ?>
    </div>
   <div id="stock">
    <?php include("include/stock.html"); ?>
    </div> 
   <!----------------------------------------Hot News----------------------------------------->
     <div id="hotnews">
     	<div class="title"></div>
        <div class="hot">
       	  <ul>
          <?php
		  $hotsql="SELECT n.NewsID, n.Title, n.Image FROM news n WHERE n.IsDeleted=0 AND n.IsReview=1 ORDER BY n.Views DESC LIMIT 0,5 ";
		  $reshot=mysql_query($hotsql);
		  while($hot=mysql_fetch_assoc($reshot))
		  {
		  ?>
            	<li> 
                	<img src="<?php echo $urlNews.$hot["Image"]; ?>" alt="" style="width:80px; height:50px" />
                    <a href="Detail.php?id=<?php echo $hot["NewsID"]; ?>"><?php echo $hot["Title"]; ?></a>
                </li>
          <?php
		  }
		  ?>
               
            </ul>
       </div>
    </div>
    <!-----------------------------------Vote---------------------------------------------->
    <div id="vote">
    	<div class="title"></div>
        <div class="hot">
        <form method="get" action="captcha/confirm.php" target="_blank">
        <?php
			$votesql="SELECT v.VoteID, v.VoteName, v.Content FROM vote v WHERE v.IsDeleted=0 AND v.IsEnd=0  AND '$listTopic' LIKE CONCAT('%<',v.TopicID,'>%') ORDER BY v.CreatedDate desc LIMIT 0,1"; 
			$resvote=mysql_query($votesql);
			$vote=mysql_fetch_assoc($resvote);
			echo $vote["Content"];
			
		?>
            <ul>
            <?php
			$vdsql="SELECT v.VoteDetailID, v.Content FROM votedetail v WHERE v.VoteID=".intval($vote["VoteID"])." ORDER BY v.VoteDetailID";
			$resvd=mysql_query($vdsql);
			$k=0;
			while($dt=mysql_fetch_assoc($resvd))
			{
			?>
            	<li><label><input type="radio" name="answer" <?php if($k==0) echo "checked='checked'"; ?> value="<?php echo $dt["VoteDetailID"]; ?>"  /><?php echo $dt["Content"]; ?></label></li>
            <?php
			$k++;
			}
			?>
                <!--<li><label><input type="radio" name="answer" id="cauB" value="" />Đức</label></li>
                <li><label><input type="radio" name="answer" id="cauC" value="" />Pháp</label></li>
                <li><label><input type="radio" name="answer" id="cauD" value="" />Đội bóng khác</label></li> -->
            </ul>
           <?php
			if(mysql_num_rows($resvote)>0)
			{
			?>
            <a id="bieuquyet" target="_blank" href="include/StatisticResult.php?voteid=<?php echo $vote["VoteID"];  ?>">Thống kê</a>&nbsp;&nbsp;<input type="submit" value="Biểu quyết" />
            <?php
			}
			?>
          </form>
       </div>
    </div>
    
    <!-------------------------------------Advertisement-------------------------------------------->
    <div id="advertisement_right">
    	<div class="title"></div>
        <div class="hot">
       	  	
            <ul>
            <?php 
			$query="SELECT a.AdvertiseName, a.FileType, a.FilePath, a.Link FROM advertisement a WHERE a.`Position`=4 AND a.IsDeleted=0 ORDER BY a.CreatedDate desc limit 0,5";
			
			$adver=mysql_query($query);
			while($row=mysql_fetch_assoc($adver))
			{
			
			switch($row['FileType'])
			{
				case 0:
				?>
				 <li><a href="<?php echo $row['Link']; ?>"><img alt="" src="<?php echo $urlAds.$row['FilePath']; ?>"   /></a></li>
				<?php
				break;
				case 1:
				?>
					<object width="250"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
			<param value="quangcao/qc1.swf" name="movie">
			<param value="high" name="quality">
			<embed width="250"  type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" quality="high" src="<?php echo $urlAds.$row['FilePath']; ?>">
			</object>
				<?php
				break;
			}
		
			}
			?>
              
          </ul>
           
       </div>
    </div>
  </div>

  
  
  <!------------------------------Footer--------------------------------------------------->
  <div class="footer">
  	<p>
    	Designed by: Nguyen Minh Nhat<br />
        Email: mimhnhat2110@gmail.com<br />
        Mobile: 0908311627
    </p>
  </div>
</div>

 
</body>
</html>